import {
	setStorage,
	getStorage
} from '@/utils/storage.js'
const TOKEN = 'token'
export default {
	namespaced: true,
	state: {
		address: getStorage('my_address') || {},
		token: getStorage(TOKEN)
	},
	getters: {
		addressStr(state) {
			return state.address.provinceName + state.address.cityName + state.address.countyName + state.address
				.detailInfo
		}
	},
	mutations: {
		updateAddress(state, payload) {
			state.address = payload
			setStorage('my_address', payload)
		},
		setToken(state, payload) {
			state.token = payload
			setStorage(TOKEN, payload)
		}
	}
}
